package com.jiexinyun.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import java.util.ArrayList;
import java.util.List;

public class ExcelDataListener<T> extends AnalysisEventListener<T> {

    private final List<T> dataList = new ArrayList<>();

    private final Class<T> clazz;

    public ExcelDataListener(Class<T> clazz) {
        this.clazz = clazz;
    }

    @Override
    public void invoke(T data, AnalysisContext context) {
        dataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        // 所有数据解析完成
    }

    public List<T> getDataList() {
        return dataList;
    }
}
